package com.example.qundui.learndemo.netutils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created by qundui on 2017/4/26.
 */

public class StringTools {
    public static  String  StringtoInpustream(InputStream inputStream){
        ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();

        int i=-1;
        try {
            while((i=inputStream.read())!=-1){
                byteArrayOutputStream.write(i);


            }
            return byteArrayOutputStream.toString("utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }


        return null;
    }
    public   static   String   inputStream2String(InputStream   is)   throws   IOException{
        ByteArrayOutputStream   baos   =   new   ByteArrayOutputStream();
        int   i=-1;
        while((i=is.read())!=-1){
            baos.write(i);
        }
        return   baos.toString();
    }
}
